package com.hospital.hms.service.impl;

import cn.hutool.core.map.MapUtil;
import com.hospital.hms.utils.PageUtils;
import com.hospital.hms.dao.mapper.MedicalDeptSubDao;
import com.hospital.hms.service.MedicalDeptSubService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Map;
@Service
public class MedicalDeptSubServiceImpl implements MedicalDeptSubService {
    @Autowired
    private MedicalDeptSubDao medicalDeptSubDao;
    @Override
    public PageUtils selectConditionByPage(Map param) {
        long count = medicalDeptSubDao.selectConditionByPageCount(param);
        if (count==0){
            return new PageUtils
                    (Collections.emptyList(),count,
                            MapUtil.getInt(param,"page"),
                            MapUtil.getInt(param,"length"));
        }else {
            return new PageUtils(medicalDeptSubDao.selectConditionByPage(param),count,
                    MapUtil.getInt(param,"page"),MapUtil.getInt(param,"length"));
        }

    }
}
